<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>同舟管理系统</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="Content-Type" content="application/x-www-form-urlencoded">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<script src="<%=basePath%>js/json.js" charset="utf-8" type="text/javascript"></script>
	<script src="<%=basePath%>js/prototype.js" charset="utf-8" type="text/javascript"></script>
			
	<script language="javascript">
	function check(){	
		if(document.getElementById("username").value==""){
			alert("用户名不能为空！");
			document.getElementById("username").focus();
			return false ;
		}
		if(document.getElementById("password").value==""){
			alert("密码不能为空！");
			document.getElementById("password").focus();
			return false ;
		}
		var judgment2;
		//var code=document.getElementById("code").value;
		var username=encodeURIComponent(document.getElementById("username").value);
		var password=document.getElementById("password").value;
       // var url = "<%=basePath%>admin/login!checkCode.action?code="+code;
		//new Ajax.Request(url,{method:'post',asynchronous:false,
       //    	onComplete:function(json){
       //    	judgment=json.responseText.parseJSON().judgment;
		//    if(judgment=="1"){
		//    	alert("验证码错误！");
	//	    }
     //      }
    //    });
     //   if(judgment!="0"){
     //   	return false;
     //   }
      var username=encodeURIComponent(document.getElementById("username").value);
		var password=document.getElementById("password").value;
        var url2 = "<%=basePath%>admin/login!checkUser.action?password="+password+"&username="+username;
        new Ajax.Request(url2,{method:'post',asynchronous:false,
           	onComplete:function(json){
           	judgment2=json.responseText.parseJSON().judgment2;
		    if(judgment2=="1"){
		    	alert("用户名或者密码错误！");
		    }
           }
        });
        if(judgment=="0"&&judgment2=="0"){
         	return true;
        }else{
         	return false;
        }
	}
	function changeCode(){
		document.getElementById("codeImg").src="<%=basePath%>common/code.jsp?"+Math.random()*1000;
	}
	
	</script>
  </head>
  <body style="margin:0 0 0 0;" >
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="150px">
			&nbsp;
			<div align="center">
			<font color="red" style="font-size:12px;">
				<s:actionerror/>
			</font>
			</div>
		</td>
      </tr>
      <tr>
        <td>
			<table width="980px" border="0" cellspacing="0" cellpadding="0" align="center">
				<tr>
					<td width="980px" height="76px" background="images/login_03.gif">
						&nbsp;
					</td>
				</tr>
				<tr>
					<td>
						<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
							<tr>
								<td width="492px" height="282px" background="images/login_07.gif">&nbsp;</td>
								<td>
									<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
									<tr>
										<td width="348px"  height="171px" valign="top">
										<form onsubmit="return check()" method="post" action="<%=basePath%>admin/login!inlogin.action" >
											<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
												<tr>
													<td align="right" style="font-size: 12px;" height="30px">用户名：</td>
													<td><input type="text" name="username" id="username" maxlength="30" value=<s:property value="username"/> >
													</td>
												</tr>
												<tr>
													<td align="right" style="font-size: 12px;" height="30px">密&nbsp;&nbsp;码：</td>
													<td><input type="password" name="password" maxlength="30" id="password"/></td>
												</tr>
												<tr>
													<td height="40px">&nbsp;</td>
                          							<td valign="bottom"><input type="image" value="登录" src="images/login_btn.gif"></td>
												</tr>
												<tr>
													<td>&nbsp;</td>
													<td>&nbsp;</td>
												</tr>
											</table>
										</form>
										</td>
										<td valign="top" height="170px" background="images/login_11.gif">&nbsp;</td>
									</tr>
									<tr>
										<td  height="111px" valign="top" background="images/login_17.gif">&nbsp;</td>
										<td  height="111px" background="images/login_18.gif">
											&nbsp;
										</td>
									</tr>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td>
						&nbsp;
					</td>
				</tr>
	        </table>
        </td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table>
    </td>
  </tr>
</table>
</body>
</HTML>